import request from '../util/request.js'

export const state = () => ({
  type: [],
  project: []
})

export const mutations = {

}

export const actions = {
  // 获取标签
  getType ({commit}, {data, cb}) {
    request.$get('/api/type/list', data, (response) => {
      cb && cb(response)
    })
  },
  // 获取专题列表
  getProject ({commit}, {data, cb}) {
    request.$get('/api/project/list', data, (response) => {
      cb && cb(response)
    })
  },

  // addProject ({commit}, {data, cb}) {
  //   request.$post('/api/updateproject', data, (response) => {
  //     cb && cb(response)
  //   })
  // },

  // addType ({commit}, {data, cb}) {
  //   request.$post('/api/updatetype', data, (response) => {
  //     cb && cb(response)
  //   })
  // },
  // 添加文章
  addNews ({commit}, {data, cb}) {
    request.$post('/api/article/add', data, (response) => {
      cb && cb(response)
    })
  },
  // 用户登录
  login ({commit}, {data, cb}) {
    request.$post('/api/user/login', data, (response) => {
      cb && cb(response)
    })
  },
  // 删除文章
  deletNews ({commit}, {data, cb}) {
    request.$post('/api/article/delete', data, (response) => {
      cb && cb(response)
    })
  },
  // 获取文章列表
  getNews ({commit}, {data, cb}) {
    request.$get('/api/article/list', data, (response) => {
      cb && cb(response)
    })
  },
  // 删除专题
  deleteProject ({commit}, {data, cb}) {
    request.$post('/api/project/delete', data, (response) => {
      cb && cb(response)
    })
  },
  // 删除专题
  deleteType ({commit}, {data, cb}) {
    request.$post('/api/type/delete', data, (response) => {
      cb && cb(response)
    })
  },
  // 记录文章点击量
  addIp ({commit}, {data, cb}) {
    request.$get('/api/ip/add', data, (response) => {
      cb && cb(response)
    })
  }
}
